import Vue from 'vue'
import App from './App'
import router from './router'
import element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import "babel-polyfill";
import infiniteScroll from 'vue-infinite-scroll'
import VideoPlayer from 'vue-video-player'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import common from "./utils/common";
Vue.use(common)
Vue.use(mavonEditor)
Vue.use(VideoPlayer);
Vue.use(infiniteScroll)
Vue.use(element)
Vue.config.productionTip = false



new Vue({
  el: '#app',
  router,
  render: h => h(App),
  watch:{
    router:router.beforeEach((to, from, next) => {
      if (to.meta.loginRequest === true || to.meta.loginRequest === undefined){
        if (JSON.parse(localStorage.getItem("userData")) !== null){
          next();
        }else {
          next('/login');
        }
      }else {
        next();
      }
    })
  }
}).$mount("#app")






